<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="event" onkeydown="" value="">
    <button id="btn">提交</button>
    <script>
        // // 1.键盘监听是否按下enter键
        // function Login(event){
        //     var e = event || window.event || arguments.callee.caller.arguments[0] ;
        //     if ( e && e.keyCode == 13 ){//监听按键enter
                
        //     }
        // }
        document.onkeydown = function ( event ){
            var e = event || window.event || arguments.callee.caller.arguments[0] ;
            if ( e && e.keyCode == 13 ) {
                document.getElementById("btn").click();
            }
        }
        document.getElementById("btn").onclick = function (){
            // 监听之后需要执行的代码
        }
    </script>
</body>
</html>